<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="images/favicon.ico">

    <title>同昌官网</title>
    <!-- Bootstrap core CSS -->
    <link href="js/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="js/bootstrap-3.3.7/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
    <link href="js/bootstrapValidator/bootstrapValidator.css" rel="stylesheet">


    <!-- custom style-->
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/forum/forum.css">
    <link href="plugs/summernote-0.8.9/summernote.css" rel="stylesheet">
    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]>
    <script src="js/bootstrap-3.3.7/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="js/bootstrap-3.3.7/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="js/bootstrap-3.3.7/js/html5shiv.min.js"></script>
    <script src="js/bootstrap-3.3.7/js/respond.min.js"></script>
    <![endif]-->
</head>
<body oncontextmenu=self.event.returnValue=false onselectstart="return false">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="width:450px;">
            <div class="modal-body">
                <form class="form-signin" id="loginForm">
                    <div class="header row">
                        <div class="col-sm-4"><span></span></div>
                        <div class="col-sm-4 ">网站登录</div>
                        <div class="col-sm-4"><span></span></div>
                    </div>
                    <div class="form-group">
                        <span class="userLabel">用户名 <i></i></span>
                        <input type="text" class="form-control" name="username" id="userName" required autofocus
                               placeholder="请输入用户名"/>
                    </div>
                    <div class="form-group">
                        <span class="passwordLabel">密码 <i></i></span>
                        <input type="password" class="form-control" name="password" id="password" required
                               placeholder="请输入密码"/>
                    </div>
                    <div class="form-group">
                        <button type="submit" id="submitBtn" class="btn btn-lg btn-primary btn-block">登录</button>
                    </div>
                </form>

            </div>
        </div>
    </div>
</div>
<nav class="navbar navbar-default navbar-static-top" id="forum">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="dcwo.html"><img src="images/forum/login.png" alt=""></a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <ul class="nav navbar-nav pull-right">
                    <li class="loginBtn"  style="color:#fff;padding-right:10px;">登录</li>
                    <!-- <li><a href="#">注册</a></li>-->
                    <li><a href="#" class="line"></a></li>
                   <!-- <li><a href="#" class="searchIcon"></a></li>-->
                    <li><a href="#" class="weixin"></a></li>
                    <!--<li><a href="#" class="en"></a></li>-->
                </ul>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
</nav>
<section class="item forum">
    <div class="container">
        <div class="forumInner">
            <div class="forumTop bgf">
                <div class="forumTitle "><span class="badge"></span></div>
                <div class="forumSubtitle clearfix ">
                    <span class="publishPerson left"></span>&nbsp;&nbsp;&nbsp;
                    <span class="publishTime left"></span> 发表在同昌话馆
                    <span class="readCount count"><i></i><span class="rCount"></span></span>
                    <span class="seeCount count"><i></i><span class="sCount"></span></span>
                    <div></div>
                </div>
                <div class="line"></div>
                <div class="forumTextBox ">
                    <div class="forumText"></div>
                    <img src="images/forum/tupian.png" alt="" class="center-block">
                </div>
                <div class="line"></div>
                <div class="replyInputBox">
                    <form class="form-inline">
                        <div class="form-group">
                            <label for="replyInput" class="replayLabel">
                                <img src="images/forum/person.png" alt="">
                            </label>
                            <input type="text" class="form-control" id="replyInput" placeholder="请输入回复信息">
                        </div>
                        <button type="button" class="btn submitReplay">发表</button>
                    </form>
                </div>
            </div>
            <div class="forumMiddle bgf">
                <div class="replyLatest ">
                    <div class="replyLatestTitle clearfix">
                        <div class="latestLeft item">最新评论 <span>|&nbsp;&nbsp;正序排列</span></div>
                        <!--<div class="latestRight item"><span>只看楼主&nbsp;&nbsp;|&nbsp;&nbsp;楼层直达:</span>
                            <input type="text" class="floor " style="width:80px;border:1px solid #eee;display:inline">
                        </div>-->
                        <div class="latestRight item">共计回复数:&nbsp;<span class="replyNumber"></span>&nbsp;条</div>
                    </div>
                    <div class="replyLatest">
                        <table style="width:100%;">
                            <tbody id="replyLatestBody"></tbody>
                        </table>
                    </div>
                    <div class="pageBox">
                        <div id="replyPage"></div>
                    </div>

                </div>
            </div>
            <!--<div class=" forumBottom clearfix bgf">
                <div class="richEditorContent ">
                    <div class="richIcon item"><img src="images/forum/person.png" alt=""></div>
                    <div id="summernote" class="item"><p>Hello Summernote</p></div>
                </div>
                <div class="richReplyBtn">
                    发表
                </div>
            </div>-->
        </div>
    </div>
</section>
<footer class="footer wow fadeInUp animated" style="visibility: visible; animation-name: fadeInUp;">
    <div class="container">
        <div class="row">
            <div class="col-xs-12">
                <div class="footTitle"><img src="images/common/footerLogo.png" alt=""></div>
            </div>
        </div>
        <div class="row footContent">
            <div class="col-xs-12 col-sm-7">
                <div class="row">
                    <div class="col-xs-3">
                        <div class="footItems">关于我们</div>
                        <div class="footItem">
                            <a href="javascript:void(0)">关于同昌</a>
                            <a href="javascript:void(0)">发展历程</a>
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <div class="footItems">加入我们</div>
                        <div class="footItem">
                            <a href="javascript:void(0)">社会招聘</a>
                            <a href="javascript:void(0)">校园招聘</a>
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <div class="footItems">联系我们</div>
                        <div class="footItem">
                            <a href="javascript:void(0)">客户服务</a>
                            <a href="javascript:void(0)">合作洽谈</a>
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <div class="footItems">服务热线</div>
                        <div class="footItem">
                            <a href="javascript:void(0)">400-653-0677</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12 col-sm-5 line">
                <div class="row">
                    <div class="col-xs-6  col-sm-5  col-sm-offset-1">
                        <div class="ewm">民生之钥</div>
                        <img src="images/common/mszy.png" alt=""></div>
                    <div class="col-xs-6 col-sm-5">
                        <div class="ewm">关注同昌</div>
                        <img src="images/common/jt.png" alt="">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="segmenLine"></div>
            </div>
        </div>
        <div class="row ">
            <div class="col-xs-12 footText">
                <div>法律声明 | 监督举报 | 网站地图 | 晋网文【2018】6138-1456号</div>
                <div>Copyright 1996 - 2018 Topchance. All Rights Reserved.中科同昌信息技术集团</div>
            </div>
        </div>
    </div>
</footer>
<!--回到顶部-->
<div id="jump"></div>
<script src="js/jquery-v1.12.4/jquery.min.js"></script>

<!--vendor-->
<script>window.jQuery || document.write('<script src="js/bootstrap-3.3.7/js/jquery.min.js"><\/script>')</script>
<script src="js/bootstrapValidator/bootstrapValidator.min.js"></script>
<script src="js/bootstrap-3.3.7/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/bootstrap-3.3.7/js/ie10-viewport-bug-workaround.js"></script>
<!-- custom -->

<!--富文本编辑器-->
<!-- include summernote css/js -->

<script src="plugs/summernote-0.8.9/summernote.js"></script>
<script src="plugs/layer/layer.js"></script>
<script src="js/bootstrap-3.3.7/js/bootstrap-paginator.min.js"></script>

<script src="js/common.js"></script>
<link rel="stylesheet" href="plugs/sweetalert2/sweetalert2.min.css">
<script src="plugs/sweetalert2/sweetalert2.all.min.js"></script>
<script src="plugs/layer/layer.js"></script>
<script >
      $(document).ready(function () {
       /*   $('#summernote').summernote({
              height: 200,
              focus: true
          });*/
          var user = window.sessionStorage.username;//获取绘话中的用户名
          $(".loginBtn").html(user);
          $(window).scroll(function() {
              if ($(window).scrollTop() > 300) {
                  $('#jumpTop').fadeIn(800);
              } else {
                  $('#jumpTop').fadeOut(800);
              }
          });
          $("#jumpTop").click(function() {
              $('body,html').animate({
                      scrollTop: 0
                  },
                  1000);
              return false;
          });

          //防下载
          document.onkeydown = function() {
              var e = window.event || arguments[0];
              //屏蔽F12
              if(e.keyCode == 123) {
                  return false;
                  //屏蔽Ctrl+Shift+I
              } else if((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
                  return false;
                  //屏蔽Shift+F10
              } else if((e.shiftKey) && (e.keyCode == 121)){
                  return false;

              } else if(event.ctrlKey  &&  window.event.keyCode==83 ){
                  return false;
              }
          };
          //屏蔽右键单击
          document.oncontextmenu = function() {
              return false;
          }
      });
    
    //获取对标题的回复内容 跳转页面需要获取的信息
    var  forumId = '';
    $(document).ready(function () {
        //富文本编辑器
        $('#summernote').summernote({
            height: 200,
            focus: true
        });
         forumId = parseInt(window.location.search.substring((window.location.search).length - 1));//论坛ID
        getPageInfo(forumId);
        //console.log($("#replyLatestBody"));
       // getPage(1, "replyLatestBody", "replyPage");
    });

    function getPageInfo(forumId) {
        $.ajax({
            url: "http://www.tpccn.com/eye/a/tcoa/forum/form", //查看论坛
            type: 'post',
            data: {id: forumId},
            success: function (data) {
                if (data) {
                    data = JSON.stringify(data);
                    data = JSON.parse(data);
                    if (data.forumtitle == 0) {
                        later.msg("获取论坛信息失败");
                    } else {
                        $(".forumTitle").html(data.forumtitle);    //阅读标题
                        $(".publishPerson").html(data.creatername);        //发布人
                        $(".publishTime").html(data.creationtime);                //发布时间
                        $(".sCount").html(data.viewnumber);                             //查看数量
                        $(".rCount").html(data.replies);                                          //回复数量
                        //if(data.freplyList == undefined || data.freplyList == null || data.freplyList == ''){}
                        if (data.freplyList) {
                            var freplyList = data.freplyList; //获取回复列表
                            console.log(freplyList);
                            var replyNumber  = parseInt(freplyList.length);
                            console.log(replyNumber);
                            $(".replyNumber").html(replyNumber);
                            $.each(freplyList, function (index, value) {
                               // console.log(value);
                                var replyHtml = '';
                                var replyPerson = value.creatername;//作者姓名
                                var replyTime = value.creationtime;//回去时间
                                var replyText = value.replycontent;  //获取内容
                                replyHtml += '<tr><td style="width:100%"><li class="clearfix"><div class="replyIcon item"><img src="images/forum/person.png" alt=""></div>\n' +
                                    '                                <div class="replyText item">\n' +
                                    '                                    <div class="row">\n' +
                                    '                                        <div class="col-sm-8">\n' +
                                    '                                            <div class="replyDetails">\n' +
                                    '                                                <div class="replyTop">\n' +
                                    '                                                    <span class="replyPerson">' + replyPerson + '</span> 发表于 <span class="replyTime">' + replyTime + '</span>\n' +
                                    '                                                </div>\n' +
                                    '                                                <div class="replyText">' + replyText + '</div>\n' +
                                    '                                            </div>\n' +
                                    '                                        </div>\n' +
                                    '                                        <div class="col-sm-4 text-right">\n' +
                                    '                                            <div class="floorNum">1+</div>\n' +
                                    '                                            <div class="replyAction">回复</div>\n' +
                                    '                                        </div>\n' +
                                    '                                    </div>\n' +
                                    '\n' +
                                    '                                </div>\n' +
                                    '                            </li></td></tr>';
                                $("#replyLatestBody").append($(replyHtml));
                            });
                           

                            /*  var replyPerson = freplyList[0].creatername;//作者姓名
                              var replyTime = freplyList[0].creationtime;//回去时间
                              var replyText = freplyList[0].replycontent;  //获取内容*/

                        } else {
                            var msg = '<span class="emptyText">暂无回复内容</span>';
                            $("#replyLatestBody").append($(msg));
                        }

                        getPage(1,"replyLatestBody","replyPage");

                        
                    }
                }
            },
            error: function (data) {
                
                layer.msg("发送ajax失败");
            }
        })
    }

    // 发表信息需要获取的信息
    $(".submitReplay").click(function () {
        var replyToTitle = $.trim($("#replyInput").val());//获取对标题的回复
        var username = window.sessionStorage.username;//获取绘话中的用户名
        if (replyToTitle && username) {
            // parent.$("#childTitle").val(replyToTitle);
           // alert(username);
           
            $.ajax({
                url: "http://www.tpccn.com/eye/a/tcoa/forum/saveFreply",
                type: "post",
                data: {creatername: username, forumid: forumId, replycontent: replyToTitle, creater: 545},
                success: function (data) {
                    if (data) {
                        layer.msg("保存回复成功");
                       // getPageInfo(forumId);
                        data = JSON.stringify(data);
                        data = JSON.parse(data);
                        if (parseInt(data.bczt) === 0) {
                            layer.msg("保存回复成功");
                            var $replyLatestBody = $("#replyLatestBody");
                            $("#replyInput").val(" ");
                            $replyLatestBody.empty();
                            getPageInfo(forumId);
                        }
                        if (parseInt(data.bczt) === 1) {
                            layer.msg("保存回复失败");
                        }
                    }
                },
                error: function (xhr, data) {
                    layer.msg("ajax请求失败");
                }
            })
        }
        else {
            if (!username) {
                layer.msg("登录后才可以回复信息!!!");
            }
            if (!replyToTitle) {
                layer.msg('回复信息不能为空！！！');
            }

        }
    });


    // modal  居中显示
    var $m_btn = $('.loginBtn');
    var $modal = $('#myModal');

    $modal.on('show.bs.modal', function () {
        var $this = $(this);
        var $modal_dialog = $this.find('.modal-dialog');
        // 关键代码，如没将modal设置为 block，则$modala_dialog.height() 为零
        $this.css('display', 'block');
        $modal_dialog.css({'margin-top': Math.max(0, ($(window).height() - $modal_dialog.height()) / 2)});
    });
    $('#myModal').on('shown.bs.modal', function () {
        $("#loginForm").bootstrapValidator({
            live: 'enabled',//验证时机，enabled是内容有变化就验证（默认），disabled和submitted是提交再验证
            excluded: [':disabled', ':hidden', ':not(:visible)'],//排除无需验证的控件，比如被禁用的或者被隐藏的
            submitButtons: '#submitBtn',//指定提交按钮，如果验证失败则变成disabled，但我没试成功，反而加了这句话非submit按钮也会提交到action指定页面
            message: '通用的验证失败消息',//好像从来没出现过
            feedbackIcons: {//根据验证结果显示的各种图标
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                username: {
                    message: '用户名验证失败',
                    validators: {
                        notEmpty: {
                            message: '用户名不能为空'
                        }
                    }
                },
                password: {
                    validators: {
                        /* regexp: {//正则验证
                             regexp: /^[a-zA-Z0-9_\.]+$/,
                             message: '所输入的字符不符要求'
                         },*/
                        notEmpty: {
                            message: '密码不能为空'
                        }
                    }
                },
            }
        });
        $("#submitBtn").click(function (e) {
            e.preventDefault();
            $("#loginForm").bootstrapValidator('validate');//提交验证
            if ($("#loginForm").data('bootstrapValidator').isValid()) {
                var username = $.trim($("#userName").val());
                var password = $.trim($("#password").val());
                $.ajax({
                    url: "http://www.tpccn.com/eye/a/tcoa/login/manage",
                    type: "post",
                    data: {username: username, password: password},
                    success: function (data) {
                        if (data) {
                            data = JSON.stringify(data);
                            data = JSON.parse(data);
                            if (data.loginmark == 1) {
                                $('#myModal').modal('hide');
                                swal(
                                    '恭喜登录成功！',
                                    'success'
                                );


                                // sessionStorage.useId = data.id;
                                // alert(id);//保存用户名id
                                sessionStorage.username = data.username;    //保存用户名
                                //  alert()
                                $(".loginBtn").html(data.username).removeClass("loginBtn");
                            }
                            if (data.loginmark == 2) {
                                swal({
                                    title: '用户名或密码填写错误登录失败,是否重新登录？',
                                    type: 'warning',
                                    showCancelButton: true,
                                    confirmButtonColor: '#3085d6',
                                    cancelButtonColor: '#d33',
                                    confirmButtonText: '确定',
                                    cancelButtonText: '取消',
                                    confirmButtonClass: 'btn btn-success',
                                    cancelButtonClass: 'btn btn-danger',
                                    buttonsStyling: false
                                }).then(function () {
                                    swal({
                                        title: '请重新核对填写信息',
                                        text: '2秒后自动关闭。',
                                        timer: 2000
                                    }).then(
                                        function (dismiss) {
                                            if (dismiss === 'timer') {
                                            }
                                        }
                                    )
                                }, function (dismiss) {
                                    if (dismiss === 'cancel') {
                                        swal(
                                            '警告！',
                                            '您确定已放弃登录:)',
                                            'warning'
                                        );
                                    }
                                });
                                //layer.alert('用户名或密码填写错误', {icon: 2});
                                $("#loginForm").data("bootstrapValidator").destroy();
                                $('#loginForm').data('bootstrapValidator', null);
                                $("#loginForm")[0].reset();
                            }
                        }
                    },
                    error: function (xhr, data) {
                        swal('发送ajax失败');
                    },
                    complete: function () {
                        $("#loginForm").data("bootstrapValidator").destroy();
                        $('#loginForm').data('bootstrapValidator', null);
                        $("#loginForm")[0].reset();
                    }
                })
            }

        });
    });
</script>

</body>
</html>
